home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
SD2.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-05-15
|
15KB
|
412 lines
;------------------------------------------------------------------------------;
; ;
; ;
; ;
; Switch Directory - SD ;
; ;
; ;
; ;
;Usage ;
; ;
; [d:\....]>SD [drive][switch][subdirectory name] ;
; ;
; [drive] - the drive to search (if not searhing ;
; current drive) ;
; ;
; [switch] = blank - search whole disk ;
; ;
; = \ - search only subdirectories of the ;
; current directory ;
; ;
; = / - search only one path deep. Searches ;
; the root directory only. (Similar ;
; to DOS CD command with one pathname) ;
; ;
; ;
; ;
; [subdirectory name] - the name of an individual ;
; subdirectory (not the ;
; complete path) ;
; ;
; If the command line is left blank then you are ;
; taken to the root directory of the disk ;
; ;
; ;
;Sorce code heavily dependent on Vern Buerg's LDIR program. Thanks Vern ;
; ;
;3/11/87 - Stephen Falatko ;
; ;
;Written for the A86 assembler ;
; ;
;------------------------------------------------------------------------------;
; Simple change directory
CODE SEGMENT
Org 0100
Stackx Dw 0 ;Entry stack pointer
Mov Stackx,SP ;Save stack ptr for exiting
Jmp Start
;
; Data Areas, Constants, Etc.
LF Equ 10
CR Equ 13
Stopper Equ 255 ;Ends print strings
CURDSK Equ 019 ;Get current disk
SETDTA Equ 01A ;Set data transfer area
CHDIR Equ 03B ;Change directory
GETPATH Equ 047 ;Get current directory
Errlvl Db 0 ;DOS return code
RootFlag Db 0
OneDeepFlag Db 0
Sub_Dir Db 16 Dup (0) ;The sub dir we want to change to
Done_Flag Dw 0
Count Dw 0 ;Number of args on command line
DtaPointer Dw DtaAreaBegin
Direction Db 0
BackOneDir Db '..',0
SearchAsciiZ Db '*.*',0
;
; Headings and titles
Not_Found_Msg Db CR,LF,'Subdirectory Not Found',CR,LF,Stopper
PathErrorMsg Db CR,LF,'Illegal \ charater in path name',CR,LF,Stopper
Help Db CR,LF,'Usage:',CR,LF,CR,LF
Db '[d:\....]>SD [drive][switch][subdirectory name]',CR,LF
Db ' [drive] - the drive to search. (if not searching',CR,LF
Db ' current drive)',CR,LF,CR,LF
Db ' [switch] = blank - search whole disk',CR,LF,CR,LF
Db ' = \ - search only subdirectories of the',CR,LF
Db ' current directory',CR,LF,CR,LF
Db ' = / - search only one path deep. Searches',CR,LF
Db ' the root directory only. (Similar',CR,LF
Db ' to DOS CD command with one pathname)',CR,LF,CR,LF
Db ' [subdirectory name] - the name of an individual',CR,LF
Db ' subdirectory (not the',CR,LF
Db ' complete path)',CR,LF
Db ' If the command line is left blank then you are',CR,LF
Db ' taken to the root directory of the disk',CR,LF,Stopper
OrigDr Db 'x:' ;Original drive
OrigDir Db '\',63 Dup (0) ; and path
RootDir Db 'x:\',0 ;To get vol label
;
; Set default drive and path
Start:
Mov AH,0D ; Reset diskettes
Int 021
Mov AH,CURDSK ; Get current disk
Int 021
Add AL,'A'
Mov OrigDr,AL ; Save original drive letter
Mov RootDir,AL ;
Mov AH,GETPATH ; Save original path
Mov DL,OrigDr
Sub DL,'@' ; a little monkey business to set
Mov SI,Offset OrigDir + 1 ; the original drive
Int 021
Mov AX,02523 ; set Ctrl+Break vector to point
Mov DX,Offset NFCB ; to our not found. This way a Ctrl+Brk
Int 021 ; will leave us in the place we started
Sub CX,CX ; Clear CX
Mov CL,B [080] ; Get the number of characters in
Cmp CX,0 ; Anything?
Jne L1
Call No_Arg ;set root dir and leave
Jmp Exit
L1:
Mov SI,081 ; set up to parse command line
Mov DI,Offset Sub_dir
Push DI
Mov DI,SI
Mov al,':' ;drive specifier present?
Repne Scasb
Cmp B [DI-1],':'
Jne L10
Mov SI,DI ;point SI to character following :
Sub DI,2 ;point DI to drive letter
Mov AL,B [DI]
Xor AL,020
Mov RootDir,AL
Sub DX,DX
Mov AH,0E ; set drive
Mov DL,AL
Sub DL,'A'
Int 021
Cmp B [SI],CR
If e Call No_Arg
Pop DI
Jmp Short L2
L10:
Pop DI
L2:
Lodsb
Cmp AL,' ' ;strip leading blanks
Jz L2
Cmp AL,0D ;carriage return
Jz L7
Cmp AL,'?' ;?
Jne L3
Cmp DI,Offset Sub_Dir ;still pointing to beginning?
Jne L3
Mov DX,Offset Help
Call PrintS
Jmp Exit ;load next
L3:
Cmp AL,'